package com.yanqu.road.server.cmd.beautyescort;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.entity.union.UnionInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.pb.beautyescort.BeautyEscortProto;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.beautyescort.BeautyEscortModule;
import com.yanqu.road.server.manger.beautyescort.BeautyEscortMgr;
import com.yanqu.road.server.manger.config.UnionConfigMgr;
import com.yanqu.road.server.manger.player.UserMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.manger.union.CrossUnionMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_BEAUTY_ESCORT_GET_CLIENT, desc = "走镖-委托人")
public class BeautyEscortGetClientCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        boolean groupOpen = player.getModule(BeautyEscortModule.class).systemOpen();
        if(groupOpen){
            BeautyEscortProto.CrossBeautyEscortClientReqMsg.Builder reqMsg = BeautyEscortProto.CrossBeautyEscortClientReqMsg.newBuilder();
            UserBaseInfo userBaseInfo = UserMgr.getUserBaseInfo(player.getUserId(), GameServer.getInstance().getServerId());
            reqMsg.setUserInfo(PlayerBasePb.parsePlayerBaseTempMsg(userBaseInfo));
            long totalGlamour = BeautyEscortMgr.getBeautyTotalGlamour(player);
            reqMsg.setTotalGlamour(totalGlamour);
            UnionInfo unionInfo = CrossUnionMgr.getUnionInfo(player.getUserInfo().getUnionUid());
            if(unionInfo != null){
                reqMsg.setUnionLv(UnionConfigMgr.getUnionLv(unionInfo.getExperience()));
            }else {
                reqMsg.setUnionLv(0);
            }
            player.sendPacket(Protocol.C_BEAUTY_ESCORT_GET_CLIENT, reqMsg);
        }
    }



    @Override
    public void sendData(GamePlayer player) {

    }
}
